<!DOCTYPE html>
<html>

<head>
    <title>游记列表</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/plugins/jquery/jquery.min.js"></script>
    <script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/travel.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>


    <script>
        $(function () {
            var params = getParams();
            //decodeURI()方法把参数转为中文
            var keyword =decodeURI(params.keyword) ;
            console.log(keyword);
            $.get('/travels/selectBykeyword',{currentPage:1,pageSize:2,keyword:keyword},function (data) {
                console.log(data.list.length);
                if(data.list.length>0){
                //重新渲染数据
                $('#allTravels').renderValues(data,{
                    'getAddress':function(item,value) {
                        var add = $(item).data('href');
                        $(item).attr('href',add+value);
                        //给a元素绑定id值,记录浏览次数时用
                        $(item).attr("data-did",value)
                    }
                });
                }else{
                    $("#allTravels").html("<span style='color: red'>sorry,暂无搜索结果</span>");
                }

            });
            $.get('/strategies/selectBykeyword',{currentPage:1,pageSize:2,keyword:keyword},function (data) {
                console.log(data);
                if(data.list.length>0) {
                    //重新渲染数据
                    $('#allStrategys').renderValues(data, {
                        'getAddress': function (item, value) {
                            var add = $(item).data('href');
                            $(item).attr('href', add + value);
                            //给a元素绑定id值,记录浏览次数时用
                            $(item).attr("data-did", value)
                        }
                    });
                }else {
                    $("#allStrategys").html("<span style='color: red'>sorry,暂无搜索结果</span>");
                }
            });

        });
    </script>
</head>

<body>


<div class="search-head">
    <div class="row nav-search">
        <div class="col-2">
            <a href="index.html">
                <span><i class="fa fa-chevron-left fa-2x"></i></span>
            </a>
        </div>
        <div class="col-10">
            <div class="input-group-sm search">
                <input class="form-control searchBtn" placeholder="搜游记">
            </div>
        </div>
    </div>
</div>
<input type="hidden" name="currentPage" id="currentPage" value="1"/>



<div class="container">
    <h5>相关游记</h5>
    <div id="allTravels">
        <div render-loop="list">
            <div class="row detail">
                <div class="col">
                    <a name="targetA" data-href="travelContent.html?id=" render-key="list.id" render-fun="getAddress">
                        <h6 render-html="list.title"></h6>
                    </a>
                    <p>
                        <a  data-href="userProfiles.html?id=" render-key="list.author.id" render-fun="getAddress">
                        <img class="rounded-circle head-img" render-src="list.author.headImgUrl">
                            <span render-html="list.author.nickName"></span> </a> 在
                        <span class="addr" render-html="list.place.name"></span>
                    </p>
                </div>
                <div class="col bigimg">
                    <a name="targetA" data-href="travelContent.html?id=" render-key="list.id" render-fun="getAddress">
                        <img render-src="list.coverUrl">
                    </a>
                </div>
            </div>

        </div>
    </div>
</div>
<hr>
<div class="container">
    <h5>相关攻略</h5>
    <div id="allStrategys">
        <div render-loop="list">
            <div class="row detail">
                <div class="col">
                    <a name="targetA" data-href="strategyCatalogs.html?strategyId=" render-key="list.id" render-fun="getAddress">
                        <h3 render-html="list.title"></h3>
                    </a>

                </div>
                <div class="col bigimg">
                    <a name="targetA" data-href="strategyCatalogs.html?strategyId=" render-key="list.id" render-fun="getAddress">
                        <img render-src="list.coverUrl">
                    </a>
                </div>
            </div>

        </div>
    </div>
</div>



</body>

</html>